﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Purchase_View.aspx.cs" Culture="en-GB"
    Inherits="Main_Accounts_VoucherDisplay_Purchase_View" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="CalendarExtenderPlus" Namespace="AjaxControlToolkitPlus" TagPrefix="advancedCalender" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Purchase View</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
    function checkbox() {
        var fromDate = document.getElementById("txtfrom");
        var todate = document.getElementById("txtto");
        
        var arrFrom = fromDate.value.split("/");
        var fromdate1 = arrFrom[1] + '/' + arrFrom[0] + '/' + arrFrom[2];
        var arrto = todate.value.split("/");
        var todate1 = arrto[1] + '/' + arrto[0] + '/' + arrto[2];
        var mainfromdate = new Date(fromdate1);
        var maintodate = new Date(todate1);
        if(mainfromdate > maintodate) {
            alert ('Start Date Should Be Less Than');
            return false;
            }
        else {
                return true;
                }
        }          
    
     function go(key, from, to, transactiontype) {
            window.open('../VoucherPrint/Voucher_Print.aspx?key=' + key + '&from=' + from + '&to=' + to + '&transactiontype=' + transactiontype);
        }
    
        function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="divmain">
        <acc:heading ID="pagehead" runat="server" HeadingText="Purchase view" />
    </div>
    <div style="width: 90%; margin-left: 5%; margin-right: 5%;">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div style="margin-left: 5%; margin-right: 5%; width: 90%" align="center">
                    <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label>
                </div>
                <table>
                    <tr>
                        <td>
                            <b>From:</b>
                        </td>
                        <td>
                            <asp:TextBox ID="txtfrom" runat="server" onkeydown="return EnabledTabKey(this.id, event);"
                                CssClass="input" ValidationGroup="Purchase" />
                            <asp:ImageButton ID="imgfrmdate" runat="server" ImageUrl="~/Images/calendar.gif" />
                            <advancedcalender:calendarextenderplus id="CalFrom" runat="server" popupbuttonid="imgfrmdate"
                                format="dd/MM/yyyy" targetcontrolid="txtfrom"></advancedcalender:calendarextenderplus>
                            <asp:RequiredFieldValidator ID="reqFromDate" runat="server" ControlToValidate="txtfrom"
                                ErrorMessage="*" ValidationGroup="Purchase"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            <b>To:</b>
                        </td>
                        <td>
                            <asp:TextBox ID="txtto" runat="server" onkeydown="return EnabledTabKey(this.id, event);"
                                CssClass="input" ValidationGroup="Purchase" />
                            <asp:ImageButton ID="Imageto" runat="server" ImageUrl="~/Images/calendar.gif" />
                            <advancedcalender:calendarextenderplus id="CalendarExtenderPlus1" runat="server"
                                popupbuttonid="Imageto" format="dd/MM/yyyy" targetcontrolid="txtto"></advancedcalender:calendarextenderplus>
                            <asp:RequiredFieldValidator ID="reqToDate" runat="server" ControlToValidate="txtto"
                                ErrorMessage="*" ValidationGroup="Purchase"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            <asp:Button ID="btnSearch_period" runat="server" Text="View" CssClass="button" OnClientClick="return checkDate();"
                                OnClick="btnSearch_period_Click" ValidationGroup="Purchase" />
                        </td>
                    </tr>
                </table>
                <div style="width: 100%; height: 10px">
                    <asp:DataList ID="DtlPurchase" runat="server" Width="100%" OnItemDataBound="DtlPurchase_ItemDataBound">
                        <ItemTemplate>
                            <table width="100%" cellspacing="0" style="border-bottom: solid 1px #818181; border-left: solid 1px #818181;
                                border-right: solid 1px #818181;">
                                <tr>
                                    <td colspan="2" style="background-color: #818181; color: White;">
                                        <div style="float: left; padding-left: 10px">
                                            <b>Voucher No: </b>&nbsp;<asp:Literal ID="ltrvoucherno" runat="server" Text='<%#Eval("TransactionNumber") %>' /><asp:HiddenField
                                                ID="htrans_id" runat="server" Value='<%#Eval("TransactionId") %>' />
                                        </div>
                                        <div style="float: right; padding-right: 10px">
                                            <b>Date : </b>&nbsp;<%#string.Format("{0:dd-MMM-yyyy}", Eval("TransactionDate"))%>
                                            <asp:HyperLink ID="hyp_print" NavigateUrl="#" runat="server"><img src="../../../Images/print.png" /></asp:HyperLink></div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="padding: 0px 10px 0px 10px; width: 100%;">
                                        <asp:GridView ID="GrdPurchase" runat="server" DataKeyNames="TransactionSerial" AutoGenerateColumns="false"
                                            OnRowDataBound="GrdPurchase_RowDataBound" Width="100%" ShowFooter="true">
                                            <Columns>
                                                <asp:TemplateField HeaderText="SNo.">
                                                    <ItemTemplate>
                                                        <%#Container.DataItemIndex+1%>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Dr/Cr" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:Literal ID="ltrdr_cr" runat="server"></asp:Literal>
                                                    </ItemTemplate>
                                                    <ItemStyle Width="75px" />
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderText="Particulars" DataField="particulars" FooterText="Total">
                                                    <FooterStyle Font-Bold="True" HorizontalAlign="Right" />
                                                    <ItemStyle Width="50%" />
                                                </asp:BoundField>
                                                <asp:TemplateField HeaderText="Debit">
                                                    <ItemTemplate>
                                                        <p style="text-align: right">
                                                            <asp:Literal ID="ltrdebit" runat="server" Text='<%#Eval("Debit") %>'></asp:Literal></p>
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        <asp:Literal ID="ltrtotdr" runat="server"></asp:Literal>
                                                    </FooterTemplate>
                                                    <FooterStyle Font-Bold="true" />
                                                    <ItemStyle HorizontalAlign="Right" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Credit">
                                                    <ItemTemplate>
                                                        <asp:Literal ID="ltrcredit" runat="server" Text='<%#Eval("Credit") %>'></asp:Literal>
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        <asp:Literal ID="ltrtotcr" runat="server"></asp:Literal>
                                                    </FooterTemplate>
                                                    <FooterStyle Font-Bold="true" />
                                                    <ItemStyle HorizontalAlign="Right" />
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top" style="padding-left: 10px; padding-right: 10px; width: 100%">
                                        <asp:Literal ID="ltrnarration_name" runat="server" Text="Narration: " />
                                        <asp:Literal ID="ltrnarration" runat="server" Text='<%#Eval("Narration") %>'></asp:Literal>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList>
                </div>
                <div id="divMessage" runat="server" style="width: 95%; text-align: center; border: solid 1px #818181;
                    height: 40px; vertical-align: middle;">
                    <asp:Label ID="lbl_noRecord" runat="server" ForeColor="Red" Text="No Record found in this period  !!!"></asp:Label>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
